<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<script type="text/javascript">
	$(document).ready(function(){
		$("#sellListBtn").click(function(){
			location.href="${initParam.root }sell.do?command=getContentList&pageNo=1";
		});//list_btn click	
		$("#sellUpdateViewBtn").click(function(){
			location.href="${initParam.root }sell.do?command=updateView&sellNo=${requestScope.svo.sellNo}&sellContentWriter=${requestScope.svo.mvo.id}";
		});//update_btn click	
		$("#sellDeleteBtn").click(function(){
			if(confirm("삭제하시겠습니까?")){
				location.href="${initParam.root }sell.do?command=deleteContent&sellNo=${requestScope.svo.sellNo}"
					+"&destFileName=${requestScope.svo.destFileName }&sellStatus=${requestScope.svo.sellStatus}"
					+"&sellContentWriter=${requestScope.svo.mvo.id}";
				}
			});//delete_btn click
		function openNewWindow(window) {
			open (window,"NewWindow","left=0, top=0, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, width=450, height=450");
		}//openNewWindow
		$("#sellMessageBtn").click(function(){
			openNewWindow("${initParam.root }message.do?command=goToMessagePopup&receiver=${requestScope.svo.mvo.id}");
			
		});//message_btn click
	});//ready
</script>


<h3>판매 글 상세보기</h3><br><br>
글번호 : ${requestScope.svo.sellNo} &nbsp; 글제목 : ${requestScope.svo.title} <br>
작성자 : ${requestScope.svo.mvo.id}
<input type="button" id="sellMessageBtn" value="쪽지보내기">
작성일자 : ${requestScope.svo.timePosted} <hr>
<h4>판매 글 내용</h4> <br>
${requestScope.svo.content} <hr>
<c:if test="${requestScope.svo.destFileName!=null }">
<h4>첨부한 사진보기</h4>
<img src="${initParam.root }upload/${requestScope.svo.destFileName }"> <hr>
</c:if>
<h4>구매 가능한 상품</h4>
<%-- <input type="checkbox" id="productName" name="${requestScope.svo.productName}"> --%>
상품명:${requestScope.svo.productName} &nbsp;&nbsp; 가격:${requestScope.svo.productPrice}원 <br><br>
<form action="${initParam.root }transaction.do" method="post">
	<input type="hidden" name="command" value="transaction">
	<!-- 판매자의 아이디 -->
	<input type="hidden" name="mvo.id" value="${requestScope.svo.mvo.id}">
	<input type="hidden" name="sellStatus" value="${requestScope.svo.sellStatus}">
	<input type="hidden" name="sellNo" value="${requestScope.svo.sellNo}">
	<input type="hidden" name="productPrice" value="${requestScope.svo.productPrice}">
	<input type="hidden" name="productName" value="${requestScope.svo.productName}">
	<c:if test="${sessionScope.userInfo.id!=requestScope.svo.mvo.id&&requestScope.svo.sellStatus=='판매중'}">
	<input type="submit" value="포인트로 구매하기"> 
	</c:if>
</form><hr>
<input type="button" id="sellListBtn" value="판매글 목록">

<!-- 상태가 '판매중' 이고 id가 판매자이면, 수정/삭제 버튼 보이게
	 id가 관리자이면, 삭제 버튼 보이게 -->
<c:if test="${((sessionScope.userInfo.id==requestScope.svo.mvo.id) &&requestScope.svo.sellStatus=='판매중') || (sessionScope.userInfo.grade=='admin')}">
	<input type="button" id="sellDeleteBtn" value="판매글 삭제">
</c:if>
<c:if test="${(sessionScope.userInfo.id==requestScope.svo.mvo.id) &&requestScope.svo.sellStatus=='판매중'}">
	<input type="button" id="sellUpdateViewBtn" value="판매글 수정">
</c:if>

